package com.sun.concurrent;

/**
 * Created by sun on 2017/1/10.
 */
public class Account {
    private double balance;//账户余额
    //private Lock accountLock = new ReentrantLock();锁


    /**
     * 存款
     * @param money 金额
     */
    public void deposit(double money) {
        double newBalance = balance + money;
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        balance = newBalance;
    }

    /**
     * 获取账户余额
     * @return 余额
     */
    public double getBalance() {
        return balance;
    }
}
